﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Tour.Linq.TourDBML;
public partial class AdminManager_Admin_TagManager_Add : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        _ReturnUrl = "Admin_TagManager.aspx";
        if (CheckEnterInfo())
        {
            _ReturnUrl = Request.Url.ToString();
            Tags tag = TourContext.Tags.SingleOrDefault(t => t.TagName.Equals(txtTagName.Text.Trim()));
            if (tag != null)
            {
                _Message = "标签：\"" + txtTagName.Text.Trim() + "\"已存在";
            }
            else
            {
                
                tag = new Tags();
                tag.TagName = txtTagName.Text.Trim();
                tag.IsTop = rbIsTop.SelectedValue.ToBoolean();
                tag.IsHot = rbIsHot.SelectedValue.ToBoolean();
                tag.IsRecommend = rbIsRecommend.SelectedValue.ToBoolean();
                TourContext.Tags.InsertOnSubmit(tag);
                TourContext.SubmitChanges();
                _Message = "添加标签成功";
            }
        }
    }

    protected override bool CheckEnterInfo()
    {
        bool isCheck = false;
        if (txtTagName.Text.IsNullOrEmpty())
        {
            _Message = "标签名不能为空";
        }
        else
        {
            isCheck = true;
        }
        return isCheck;
    }
}
